<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			uni.onTabBarMidButtonTap(() => {
				this.$goto('/pages/demand/release')
			})

			this.$store.commit('setToken');
			this.$store.commit('userLogin');
			this.$store.commit('getVer');
			this.$store.commit('getCity');

			this.checkIsFirst();
			this.getLocation();
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		data() {
			return {
				address: ''
			};
		},
		methods: {
			checkIsFirst() {
				let isFirst = uni.getStorageSync('isFirst') || ''
				if (isFirst) {

				} else {
					this.$goto('/pages/activity/firstguide')
				}
			},
			getLocation() {
				uni.getLocation({
					type: 'gcj02',
					geocode: true,
					success: res => {
						this.address = res.address
						this.$u.get('/city/choose', {
							city: res.address.city
						}).then(res => {
							this.$store.commit('setCity', res.data.result.city)
						})
					},
					fail: res => {
						console.log(res)
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import "app.scss";
	.u-cell {
		align-items: center;
	}
</style>
